//package org.myrabbitmqdemo.service;
//
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.rabbit.annotation.Exchange;
//import org.springframework.amqp.rabbit.annotation.Queue;
//import org.springframework.amqp.rabbit.annotation.QueueBinding;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.stereotype.Service;
//
///**
// * @Date 2025/6/10 11:14
// * @Author guangang
// */
//@Service
//public class ShardingExchangeService {
//    /**
//     * 队列分片sharding
//     * @param message
//     */
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(value = "sharding: sharding_exchange - rabbit@rabbitmq-new - 0", durable = "true"),
//            exchange = @Exchange(value = "sharding_exchange", type = "x-modulus-hash"),
//            key = "sharding"
//    ))
//    public void listenQueue0(Message message) {
//        System.out.print("routingKey0 > " + message.getMessageProperties().getReceivedRoutingKey());
//        try {
//            System.out.println(" " + new String(message.getBody(), "UTF-8"));
//        } catch (Exception e) {
//            System.out.println("Error decoding message: " + e.getMessage());
//        }
//    }
//
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(value = "sharding: sharding_exchange - rabbit@rabbitmq-new - 1", durable = "true"),
//            exchange = @Exchange(value = "sharding_exchange", type = "x-modulus-hash"),
//            key = "sharding"
//    ))
//    public void listenQueue1(Message message) {
//        System.out.print("routingKey1 > " + message.getMessageProperties().getReceivedRoutingKey());
//        try {
//            System.out.println(" " + new String(message.getBody(), "UTF-8"));
//        } catch (Exception e) {
//            System.out.println("Error decoding message: " + e.getMessage());
//        }
//    }
//
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(value = "sharding: sharding_exchange - rabbit@rabbitmq-new - 2", durable = "true"),
//            exchange = @Exchange(value = "sharding_exchange", type = "x-modulus-hash"),
//            key = "sharding"
//    ))
//    public void listenQueue2(Message message) {
//        System.out.print(" routingKey2 >" + message.getMessageProperties().getDeliveryTag());
//        try {
//            System.out.println(" " + new String(message.getBody(), "UTF-8"));
//        } catch (Exception e) {
//            System.out.println("Error decoding message: " + e.getMessage());
//        }
//    }
//
//
//
//
//
//
//
//
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue("my.classic2"),
//            exchange = @Exchange(value = "my.topic", type = "topic"),
//            key = "my.topic.classic"
//    ))
//    public void myDirectClassic(String message) {
//        System.out.println("接收到classic消息：" + message);
//    }
//
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue("my.quorum2"),
//            exchange = @Exchange(value = "my.topic", type = "topic"),
//            key = "my.topic.quorum"
//    ))
//    public void myDirectQuorum(String message) {
//        System.out.println("接收到quorum消息：" + message);
//    }
//
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue("my.stream2"),
//            exchange = @Exchange(name = "my.topic", type = "topic"),
//            key = "my.topic.stream"
//    ))
//    public void myDirectStream(String message) {
//        System.out.println("接收到stream消息：" + message);
//    }
//
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(value = "my.stream22", durable = "true"),
//            exchange = @Exchange(name = "my.topic", type = "topic"),
//            key = "my.topic.*"
//    ))
//    public void myDirectStream2(String message) {
//        System.out.println("接收到stream消息：" + message);
//    }
//
//}
